package com.example.gkcircle.library;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.SignUpCallback;
import com.example.gkcircle.App;
import com.example.gkcircle.R;
import com.example.gkcircle.activity.BoundLoginActivity;
import com.example.gkcircle.library.object.Book;
import com.example.gkcircle.library.object.DetailBook;
import com.example.gkcircle.library.object.GKUser;
import com.example.gkcircle.library.object.URL;
import com.example.gkcircle.library.utils.AutoGetCaptcha;
import com.example.gkcircle.library.utils.LibraryAnalysis;
import com.example.gkcircle.utils.ActivityUtil;
import com.example.gkcircle.utils.HttpClientUtil;
import com.example.gkcircle.library.utils.LibraryStringUtil;
import com.example.gkcircle.utils.ThreadPoolUtils;
import com.example.gkcircle.utils.HttpClientUtil.RequestResult;
import com.example.gkcircle.utils.ToastFactory;

/**
 *
 * @ClassName: HttpUtil
 * @Description: TODO(图书馆接口)
 * @author ZhouHua
 * @date 2015年9月4日 下午8:28:24
 *
 */
public class LibraryRequest {

	public static final int SUCCESS = 0;// 请求成功
	public static final int INTERNET_WRONG = 1;// 网络错误
	public static final int NOT_VERIFY = 2;// 身份未认证
	public static final int NOT_LOGIN = 3;// 未登录
	public static final int VERIFY_WRONG = 6;// 认证失败
	public static final int NO_READER=5; //读者已经注销
	public static final int COOKIE_POST = 7;// Cookie过期
	public static final int ID_WRONG=11; //请输入正确的读者证件号
	public static final int PASSWORD_WRONG = 13;// 密码错误
	public static final int CHANGE_PSW_SUCCESS = 14;// 修改密码成功
	public static final int CHANGE_PSW_FAILURE = 15;// 修改密码失败
	public static final int CAPTCHA_WRONG = 23;// 验证码错误
	private final String TAG="LibraryRequest";

	private static LibraryRequest mHttpUtil;

	public static LibraryRequest getInstance() {
		if (mHttpUtil == null) {
			mHttpUtil = new LibraryRequest();
		}
		return mHttpUtil;
	}



	protected ILoginByOfficeListener loginByOfficeListener;
	public interface ILoginByOfficeListener{
		void complete(String result);
	}

	public void loginByOffice(final String id, final String psw, final ILoginByOfficeListener loginByOfficeListener){
		this.loginByOfficeListener=loginByOfficeListener;

		final String url="http://61.145.231.45:6543/xscj.aspx?xh=0104130519";
		final String postUrl="http://61.145.231.45:6543/default3.aspx";
		final String loginUrl="http://61.145.231.45:6543/";

		HttpRequest.getIntance().getRequestString(loginUrl, 0, new HttpRequest.IGetStringListener() {
			@Override
			public void succeed(String result) {

				ThreadPoolUtils.execute(new Runnable() {
					@Override
					public void run() {

						HashMap<String, String> param = new HashMap<String, String>();
						param.put("__VIEWSTATE", "dDwtNjg3Njk1NzQ3O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDg+O2k8MTM+O2k8MTU+Oz47bDx0PHA8O3A8bDxvbmNsaWNrOz47bDx3aW5kb3cuY2xvc2UoKVw7Oz4+Pjs7Pjt0PHA8bDxWaXNpYmxlOz47bDxvPGY+Oz4+Ozs+O3Q8O2w8aTwwPjs+O2w8dDw7bDxpPDE+Oz47bDx0PHA8bDxpbm5lcmh0bWw7PjtsPFw8dGFibGUgd2lkdGg9JzEwMCUnIGJvcmRlcj0nMCcgY2VsbHNwYWNpbmc9JzAnIGNlbGxwYWRkaW5nPScwJ1w+XDx0clw+XDx0ZCBhbGlnbj0nY2VudGVyJ1w+XDxhIHRhcmdldD1fYmxhbmsgIGhyZWY9J2p3Z2djay5hc3B4P2Zic2o9MjAxMS0wMy0wMSsxNiUzYTU5JTNhMzkmZ2didD0lZDclZGIlYmElY2YlY2IlZDglZDYlY2ElYmYlY2UlYjMlY2MlY2QlZjglYzklY2YlZDElYTElYmYlY2UlZDYlYjglYzQlY2YmQ29kZUZsYWc9JWIwJWVmJWQ2JWZhJWNlJWM0JWJjJWZlJ1w+MjAxMS0zLTEg57u85ZCI57Sg6LSo6K++56iL572R5LiK6YCJ6K++5oyH5Y2XKOW4ruWKqeaWh+S7tilcPC9hXD5cPC90ZFw+XDwvdHJcPlw8L3RhYmxlXD5cPHNjcmlwdCB0eXBlPSd0ZXh0L2phdmFzY3JpcHQnXD52YXIgb01hcnF1ZWUgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnbXEnKVw7dmFyIGlMaW5lSGVpZ2h0ID0gMTZcO3ZhciBpTGluZUNvdW50ID0gMVw7dmFyIGlTY3JvbGxBbW91bnQgPSAxXDsgZnVuY3Rpb24gcnVuKCl7b01hcnF1ZWUuc2Nyb2xsVG9wICs9IGlTY3JvbGxBbW91bnRcO2lmICggb01hcnF1ZWUuc2Nyb2xsVG9wID09IGlMaW5lQ291bnQgKiBpTGluZUhlaWdodCApe29NYXJxdWVlLnNjcm9sbFRvcCA9IDBcO31pZiAoIG9NYXJxdWVlLnNjcm9sbFRvcCAlIGlMaW5lSGVpZ2h0ID09IDAgKSB7d2luZG93LnNldFRpbWVvdXQoICdydW4oKScsIDIwMDAgKVw7fSBlbHNlIHt3aW5kb3cuc2V0VGltZW91dCggJ3J1bigpJywgNTAgKVw7fX1vTWFycXVlZS5pbm5lckhUTUwgKz0gb01hcnF1ZWUuaW5uZXJIVE1MXDt3aW5kb3cuc2V0VGltZW91dCggJ3J1bigpJywgMjAwMCApXDtcPC9zY3JpcHRcPjs+Pjs7Pjs+Pjs+Pjs+Pjs+PjtsPGltZ0RMO2ltZ1RDO2ltZ1FNTTs+PoMUhORvTgU3dlDnrTPOqQePYQRN");
						param.put("ddlSF", "Ñ§Éú");
						param.put("imgDL.x", "35");
						param.put("imgDL.y", "16");
						param.put("tbPSW", psw);
						param.put("tbYHM", id);

						RequestResult result = HttpClientUtil.post(postUrl, App.getCookie(0), param);

						if (result != null) {
//							App.setCookie(0, "ASP.NET_SessionId=z0yhks55c2nw043qxtmdbsng; path=/");
							//loginByOfficeListener.complete(HttpClientUtil.get(url, App.getCookie(0), null).getBody());

							HttpRequest.getIntance().getRequestString(url, 0, new HttpRequest.IGetStringListener() {
								@Override
								public void succeed(String result) {
									loginByOfficeListener.complete(result);
								}

								@Override
								public void error(String error) {

									Log.i(TAG, error);
								}
							});

						} else {
							Log.i(TAG, "nothing else here");
						}
					}
				});
			}

			@Override
			public void error(String error) {

				Log.i(TAG, "get 出错"+error);

			}
		});

	}


	// 登录
	protected static ILoginListener loginListener;

	public interface ILoginListener {
		void onSuccess(GKUser user);

		void onFailure(int code);
	}

	//自动登录
	protected IAutoLoginListener autoLoginListener;
	public interface IAutoLoginListener{
		void complete(GKUser user);
	}

	public void autoLogin(final Activity activity,final IAutoLoginListener autoLoginListener){
		this.autoLoginListener=autoLoginListener;
		final GKUser user =GKUser.getCurrentUser(activity);
		if(user!=null){
			HttpRequest.getIntance().getCaptchaBitmap(new HttpRequest.IImageRequest() {
				@Override
				public void complete(Bitmap bitmap) {
					if (bitmap == null) {
						ToastFactory.getToast(activity, activity.getResources().getString(R.string.connection_error)).show();
						return;
					}
					AutoGetCaptcha.getInstanse(activity,bitmap).getCaptcha(new AutoGetCaptcha.IGetcaptchaListener() {
						@Override
						public void onComplete(String result) {
							loginByLibrary(activity, user.getUserId(), user.getPassword(), result, new ILoginListener() {
								@Override
								public void onSuccess(GKUser user) {
									autoLoginListener.complete(user);
								}

								@Override
								public void onFailure(int code) {
									ToastFactory.getToast(activity, LibraryRequest.getCodeType(code)).show();
									if(code==LibraryRequest.PASSWORD_WRONG){
										ActivityUtil.startActivity(activity,BoundLoginActivity.class);
									}
								}
							});
						}
						@Override
						public void onError(Exception e) {
							Log.i(TAG, "onError: 识别验证码失败");
						}
					});
				}
			});

		}else{
			ToastFactory.getToast(activity,activity.getResources().getString(R.string.not_login)).show();
			ActivityUtil.startActivity(activity, BoundLoginActivity.class);
		}
	}

	public void loginByLibrary(final Context context, final String userId, final String password, final String captcha, final ILoginListener li) {

		ThreadPoolUtils.execute(new Runnable() {

			@Override
			public void run() {

				LibraryRequest.loginListener = li;
				HashMap<String, String> param = new HashMap<String, String>();
				param.put("number", userId);
				param.put("passwd", password);
				param.put("captcha", captcha);
				param.put("select", userId.length() < 7 ? "bar_no" : "cert_no");
				param.put("returnUrl", URL.info);

				RequestResult result = HttpClientUtil.post(URL.login, App.getCookie(1), param);

				if (null != result) {
					Document doc = Jsoup.parse(result.getBody());
					Elements info = doc.select("table").select("td");
					// 校园网拦截检测
					if (LibraryAnalysis.isBeenStop(doc)) {
						li.onFailure(INTERNET_WRONG);
						return;
					}
					// 判断是否首次登录验证用户姓名
					if (!doc.select("dl#searchmain").select("dt").isEmpty()) {
						li.onFailure(NOT_VERIFY);
						return;
					}
					int checkStatus = info.get(15).text().length();
					switch (checkStatus) {
						case PASSWORD_WRONG:
							// 密码错误
							li.onFailure(PASSWORD_WRONG);
							return;
						case CAPTCHA_WRONG:
							// 验证码错误
							li.onFailure(CAPTCHA_WRONG);
							return;
						case NO_READER+1:
							li.onFailure(NO_READER);
							return;
						//请输入正确的读者证件号
						case ID_WRONG:
							li.onFailure(ID_WRONG);
							return;
					}
					// 解析用户信息
					GKUser user = LibraryAnalysis.analysisUserInfo(context, userId, password, info);
					// 登录成功
					li.onSuccess(user);
				} else {
					li.onFailure(INTERNET_WRONG);
				}
			}
		});
	}

	/**
	 *
	 * @Title: getCaptcha
	 * @Description: TODO(获取验证码)
	 * @return Bitmap
	 */

	protected static IGetCaptchaListener getCaptchaListener;

	public interface IGetCaptchaListener {
		void onSuccess(Bitmap bitmap);

		void onFailure(int code);
	};

	public void getCaptcha(final IGetCaptchaListener getCaptchaListener) {
		ThreadPoolUtils.execute(new Runnable() {
			@Override
			public void run() {
				try {
					HttpGet getLogin = new HttpGet(URL.captcha);
					HttpResponse response = HttpClientUtil.getHttpClient().execute(getLogin);
					App.setCookie(1, LibraryStringUtil.analysisCookie(response.getFirstHeader("Set-Cookie").toString()));
					Log.i(TAG, "App.cookie为："+App.getCookie(1));
					byte[] cap = EntityUtils.toByteArray(response.getEntity());
					getCaptchaListener.onSuccess(BitmapFactory.decodeByteArray(cap, 0, cap.length));
				} catch (RuntimeException r) {
					r.printStackTrace();
					getCaptchaListener.onFailure(INTERNET_WRONG);
				} catch (ClientProtocolException c) {
					c.printStackTrace();
					getCaptchaListener.onFailure(INTERNET_WRONG);
				} catch (IOException e) {
					e.printStackTrace();
					getCaptchaListener.onFailure(INTERNET_WRONG);
				} finally {
					// 关闭连接并释放资源
					HttpClientUtil.shutdownHttpClient();
				}
			}
		});
	}

	// 认证用户身份
	protected static IVeriryUserListener verifyUserListener;

	public interface IVeriryUserListener {
		void onSuccess();

		void onFailure(int code);
	}

	public void verifyUser(final String name, final IVeriryUserListener verifyUserListener) {

		ThreadPoolUtils.execute(new Runnable() {

			@Override
			public void run() {
				LibraryRequest.verifyUserListener = verifyUserListener;
				HashMap<String, String> param = new HashMap<String, String>();
				param.put("name", name);
				RequestResult result = HttpClientUtil.post(URL.verifyUser,App.getCookie(1), param);
				if (null != result) {
					Document doc = Jsoup.parse(result.getBody());
					Elements info = doc.select("table").select("td");
					// 校园网拦截检测
					if (LibraryAnalysis.isBeenStop(doc) || info.isEmpty()) {
						verifyUserListener.onFailure(INTERNET_WRONG);
						return;
					}
					// Was the cookie past? cookie过期判断 需要重新登录
					if (LibraryStringUtil.isCookiePast(doc)) {
						verifyUserListener.onFailure(COOKIE_POST);
						return;
					}
					int checkStatus = info.get(info.size() - 1).text().length();
					// 认证错误
					if (checkStatus == VERIFY_WRONG) {
						verifyUserListener.onFailure(VERIFY_WRONG);
						return;
					}
					// 认证成功
					verifyUserListener.onSuccess();
				} else {
					verifyUserListener.onFailure(INTERNET_WRONG);
				}

			}

		});
	}

	// 修改图书馆密码
	protected static IChangePswListener changePswListener;

	public interface IChangePswListener {
		void onSuccess();

		void onFailure(int code);
	}

	public void changePassword(final String psw, final String newPsw, final IChangePswListener changePswListener) {

		LibraryRequest.changePswListener = changePswListener;
		ThreadPoolUtils.execute(new Runnable() {

			@Override
			public void run() {
				HashMap<String, String> param = new HashMap<String, String>();
				param.put("old_passwd", psw);
				param.put("new_passwd", newPsw);
				param.put("chk_passwd", newPsw);
				param.put("submit1", "确定");
				RequestResult result = HttpClientUtil.post(URL.changePsw,App.getCookie(1), param);
				if (null != result) {
					Document doc = Jsoup.parse(result.getBody());
					// 校园网拦截检测
					if (LibraryAnalysis.isBeenStop(doc)) {
						changePswListener.onFailure(CHANGE_PSW_FAILURE);
						return;
					}
					// has password been changed successfully?
					if (LibraryStringUtil.hasChangeSuccess(doc)) {
						changePswListener.onSuccess();
						return;
						// Was the cookie past?
					} else if (LibraryStringUtil.isCookiePast(doc)) {
						changePswListener.onFailure(COOKIE_POST);
						return;
					} else {
						changePswListener.onFailure(CHANGE_PSW_FAILURE);
					}
				} else {
					changePswListener.onFailure(INTERNET_WRONG);
				}
			}
		});
	}

	// 获取图书馆个人信息
	protected static IGetUserInfoListener getUserInfoListener;

	public interface IGetUserInfoListener {
		void onSuccess(GKUser user);

		void onFailure(int code);
	}

	public void getUserInfo(final Context context, final IGetUserInfoListener getUserInfoListener) {
		LibraryRequest.getUserInfoListener = getUserInfoListener;
		// 判断是否已登录
		if (GKUser.getCurrentUser(context) == null) {
			getUserInfoListener.onFailure(NOT_LOGIN);
			return;
		}
		ThreadPoolUtils.execute(new Runnable() {
			@Override
			public void run() {
				RequestResult result = HttpClientUtil.get(URL.info, App.getCookie(1), null);
				if (null != result) {
					Document doc = Jsoup.parse(result.getBody());
					Elements info = doc.select("table").select("td");
					// 校园网拦截检测
					if (LibraryAnalysis.isBeenStop(doc)) {
						getUserInfoListener.onFailure(CHANGE_PSW_FAILURE);
						return;
					}
					// Was the cookie past?
					if (LibraryStringUtil.isCookiePast(doc)) {
						getUserInfoListener.onFailure(COOKIE_POST);
						return;
					}
					// 缓存的User
					GKUser currentUser = GKUser.getCurrentUser(context);
					// 新User
					GKUser user = LibraryAnalysis.analysisUserInfo(context, currentUser.getUserId(), currentUser.getPassword(), info);
					getUserInfoListener.onSuccess(user);
				} else {
					getUserInfoListener.onFailure(INTERNET_WRONG);
				}
			}

		});
	}

	/**
	 * 获取搜索图书结果列表
	 */

	protected static IGetSearchListListener getSearchListListener;

	public interface IGetSearchListListener {
		void onSuccess(List<Book> object);

		void onFailure(int code);
	}

	public void getSearchList(final String keyWord, final int page, final String type, final IGetSearchListListener getSearchListListener) {

		ThreadPoolUtils.execute(new Runnable() {
			@Override
			public void run() {
				LibraryRequest.getSearchListListener = getSearchListListener;
				// 封装参数
				HashMap<String, String> params = new HashMap<String, String>();
				params.put("sType0", type);
				params.put("q0", keyWord);
				params.put("with_ebook", "");
				params.put("page", page + "");
				// get请求并得到请求的数据
				RequestResult result = HttpClientUtil.get(URL.search, null, params);

				if (null != result) {
					List<Book> books = LibraryAnalysis.analysisSearchResult(result.getBody());
					if (null != books) {
						// 请求成功
						getSearchListListener.onSuccess(books);
					} else {
						// 请求失败
						getSearchListListener.onFailure(INTERNET_WRONG);
					}
				} else {
					// 请求失败
					getSearchListListener.onFailure(INTERNET_WRONG);
				}
			}
		});
	}

	protected  static IGetMoreSearchListListener getMoreSearchListListener;

	public interface IGetMoreSearchListListener{
		void onSuccess(List<Book> object);

		void onFailure(int code);
	}

	/**
	 * 高级搜索
	 */
	public void getMoreSearchList(final IGetMoreSearchListListener getMoreSearchListListener,final List<String> condition){
		ThreadPoolUtils.execute(new Runnable() {
			@Override
			public void run() {
				LibraryRequest.getMoreSearchListListener = getMoreSearchListListener;
				// 封装参数
				HashMap<String, String> params = new HashMap<String, String>();
				//题名
				params.put("title", condition.get(0));
				//出版社
				params.put("publisher", condition.get(1));
				//作者
				params.put("author", condition.get(2));
				//ISBN
				params.put("isbn", "");
				//丛书名
				params.put("series", "");
				//索书号
				params.put("callno", "");
				//主题词
				params.put("keyword", "");
				//起始年份
				params.put("year", condition.get(3));
				//文献类型
				params.put("doctype", condition.get(4));
				//语种类别
				params.put("lang_code", condition.get(5));
				//每页显示
				params.put("displaypg", "20");
				//结果显示(默认table显示)
				params.put("showmode", "table");
				//结果排序
				params.put("sort", "CATA_DATE");
				//升降序
				params.put("orderby", "desc");
				//馆藏地
				params.put("location", "ALL");
				params.put("with_ebook", "on");

				// get请求并得到请求的数据
				RequestResult result = HttpClientUtil.get(URL.moreSearch, null, params);

				if (null != result) {
					List<Book> books = LibraryAnalysis.analysisSearchResult(result.getBody());
					if (null != books) {
						// 请求成功
						getMoreSearchListListener.onSuccess(books);
					} else {
						// 请求失败
						getMoreSearchListListener.onFailure(INTERNET_WRONG);
					}
				} else {
					// 请求失败
					getMoreSearchListListener.onFailure(INTERNET_WRONG);
				}

			}
		});
	}


	// 获取详细图书信息
	protected static IGetDetailListener getDetailListener;

	public interface IGetDetailListener {
		void onSuccess(DetailBook detailBook);

		void onFailure(int code);
	};

	public void getDetailBookInfo(final String url, final IGetDetailListener getDetailListener) {
		LibraryRequest.getDetailListener = getDetailListener;
		// 获取ISBN和状态信息线程
		ThreadPoolUtils.execute(new Runnable() {

			@Override
			public void run() {
				final RequestResult result = HttpClientUtil.get(URL.detail + url, null, null);
				if (null != result) {
					// 解析到ISBN才能得到JSON
					DetailBook detailBook = LibraryAnalysis.analysisDetailBookInfo(result.getBody());

					if(detailBook.getISBN().isEmpty()){
						//成功回调数据
						getDetailListener.onSuccess(detailBook);
						return;
					}
					// 获得ISBN向豆瓣请求JSON
					RequestResult json = HttpClientUtil.get(URL.doubanAPI + detailBook.getISBN(), null, null);

					if (null != json) {
						// 解析json
						detailBook= LibraryAnalysis.analysisJson(json.getBody(), detailBook);
					} else {
						getDetailListener.onFailure(INTERNET_WRONG);
					}

					//成功回调数据
					getDetailListener.onSuccess(detailBook);
				} else {
					getDetailListener.onFailure(INTERNET_WRONG);
				}
			}

		});
	}


	// 获取用户当前借阅信息
	protected static IGetBorrowingListener iGetBorrowingListener;

	public interface IGetBorrowingListener {
		void onSuccess(List<Book> book);

		void onFailure(int code);
	};

	public void getBorrowing(final IGetBorrowingListener iGetBorrowingListener){
		LibraryRequest.iGetBorrowingListener=iGetBorrowingListener;
		ThreadPoolUtils.execute(new Runnable() {
			@Override
			public void run() {
				RequestResult result=HttpClientUtil.get(URL.borrow, App.getCookie(1), null);
				if(null!=result){
					Document doc = Jsoup.parse(result.getBody());
					Elements info = doc.select("table").select("td");
					// 校园网拦截检测
					if (LibraryAnalysis.isBeenStop(doc)) {
						iGetBorrowingListener.onFailure(CHANGE_PSW_FAILURE);
						return;
					}
					// Was the cookie past?
					if (LibraryStringUtil.isCookiePast(doc)) {
						iGetBorrowingListener.onFailure(COOKIE_POST);
						return;
					}
					List<Book> bookList=LibraryAnalysis.anlysisBorrowing(doc.toString());

					iGetBorrowingListener.onSuccess(bookList);
					return;
				}
			    iGetBorrowingListener.onFailure(INTERNET_WRONG);
			}
		});
	}

	// 获取用户历史借阅信息
	protected static IGetBorrowedListener iGetBorrowedListener;

	public interface IGetBorrowedListener {
		void onSuccess(List<Book> book);

		void onFailure(int code);
	};

	public void getBorrowed(final int page,final IGetBorrowedListener iGetBorrowedListener){
		LibraryRequest.iGetBorrowedListener=iGetBorrowedListener;
		ThreadPoolUtils.execute(new Runnable() {
			@Override
			public void run() {
				RequestResult result=HttpClientUtil.get(URL.borrowed+"?page="+page, App.getCookie(1), null);
				if(null!=result){
					Document doc = Jsoup.parse(result.getBody());
					Elements info = doc.select("table").select("td");
					// 校园网拦截检测
					if (LibraryAnalysis.isBeenStop(doc)) {
						iGetBorrowedListener.onFailure(CHANGE_PSW_FAILURE);
						return;
					}
					// Was the cookie past?
					if (LibraryStringUtil.isCookiePast(doc)) {
						iGetBorrowedListener.onFailure(COOKIE_POST);
						return;
					}
					List<Book> bookList=LibraryAnalysis.anlysisBorrowed(doc.toString());
					iGetBorrowedListener.onSuccess(bookList);
					return;
				}
				iGetBorrowedListener.onFailure(INTERNET_WRONG);
			}
		});
	}



	public static String getCodeType(int code){
		switch (code){
			case 0:
				return "请求成功";
			case 1:
				return "网络似乎有点问题";
			case 2:
				return "身份未认证";
			case 3:
				return "Cookie已过期";
			case 5:
				return "读者已经注销";
			case 6:
				return "认证失败";
			case 7:
				return "Cookie过期";
			case 11:
				return "请输入正确的读者证件号";
			case 13:
				return "密码错误";
			case 14:
				return "修改密码成功";
			case 15:
				return "修改密码失败";
			case 23:
				return "验证码错误";
			default:
				return " ";
		}
	}

}
